home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 2 / Meeting Pearls Vol. II (1995)(GTI - Schatztruhe)[!].iso / Pearls / psion / src.doc / unsorted / ml3.01 < prev    next >
Text File  |  1986-12-15  |  8KB  |  305 lines

  1. rem ML3 vers 1.01
  2. rem (c) Les Hall 1993
  3. rem CIS 71053,1676
  4.  
  5. proc ML3:
  6.     global prompt$(20),prompt&    REM Vars
  7.     local g%    REM More vars
  8.     if not exist ("M:\Miles")    REM Change "M" to A or B if you want
  9.         create "M:\Miles",a,time$,startpo$,startmi&,endpos$,endmile&,totb&,totp&
  10.     else
  11.         open "M:\Miles",a,time$,startpo$,startmi&,endpos$,endmile&,totb&,totp&
  12.     endif
  13.         last
  14.         gat 0,0
  15.         gfill 240,14,2
  16.         gat 4,10
  17.         gtmode 1
  18.         gstyle 1    REM Setting up top line of window
  19.         gprint "ML3 - Mileage logging for the Series 3"
  20.         gcreate(0,16,240,64,1)    REM Create a window for the rest
  21.     do    REM Get in the loop
  22.         gat 0,16
  23.         gstyle 9
  24.         prompt$=upper$(A.endpos$)    REM Get Last location from the file
  25.         gprintb "LAST LOCATION WAS "+prompt$,240,2    REM Show the above
  26.         gat 0,34
  27.         prompt&=A.endmile&    REM get last mileage
  28.         gprintb "LAST MILEAGE LOGGED WAS "+gen$(prompt&,10)+" MILES",240,2
  29.         gat 0,38
  30.         glineby 240,0    REM Make the screen look good with graphics
  31.         gat 0,39
  32.         glineby 240,0    REM Make the above line 'thick'
  33.         gat 0,51
  34.         gstyle 1    REM Setup prompts for user
  35.         gprintb "[ENTER] to log a trip",240,2
  36.         gat 0,62    REM another prompt
  37.         gprintb "[HELP] or [MENU] for other options",240,2
  38.         g%=get    REM Get keystrokes
  39.         if g%=13    REM Enter?
  40.             log:
  41.         endif
  42.         if g%=291    REM Help?
  43.             help:
  44.         endif
  45.         if g%=290    REM Menu key?
  46.             domenu:
  47.         endif
  48.         if kmod and 8    REM Psion key?
  49.             dopsion:(g%-512)
  50.         endif
  51.         if g%=79 or g%=111
  52.             off
  53.         endif
  54.     until g%=27    REM Esc key ALSO exits
  55. endp
  56.  
  57.  
  58. proc log:    REM This is where we write trip details to file
  59.     local d%,pick%,place$(30),mile&,lastloc$(30),lastmil&
  60.     last    REM Make sure we're at the end of the file
  61.     dinit "Log A Trip"
  62.     dposition 0,1    REM Set up Trip Dialog Box
  63.     dtext "","úLast location was "+ A.endpos$
  64.     lastloc$=A.endpos$    REM Convert some vars
  65.     dedit place$,"New location is"
  66.     prompt$=place$    REM Need this to refresh main window text
  67.     dtext "","úLast mileage was "+fix$( A.endmile&,0,10)
  68.     lastmil&=A.endmile&
  69.     dlong mile&,"New mileage is", A.endmile&+1,10000000
  70.     mile&=prompt&    REM also need this to refresh mileage shown on main window
  71.     dchoice pick%,"Kind of trip","Business,Personal"
  72.     dialog
  73.     if pick%=1    REM Business Trip
  74.         A.totb&=mile&-lastmil&    REM Assign inputs to file
  75.         A.totp&=0
  76.     elseif pick%=2    REM Personal trip
  77.         A.totp&=mile&-lastmil&    REM Assign inputs to file
  78.         A.totb&=0    REM Just in case
  79.     elseif pick%=0    REM They didn't want to record trip
  80.         return    REM so get outta here
  81.     endif
  82.     A.time$=mid$(Datim$,5,17)    REM Put date&time into record
  83.     A.startpo$=upper$(lastloc$)    REM Juggling!
  84.     A.startmi&=lastmil&    REM Juggling!
  85.     A.endpos$=upper$(place$)    REM More juggling!
  86.     A.endmile&=mile&
  87.     append    REM Write trip details to file
  88.     return
  89. endp
  90.  
  91.  
  92.  
  93. proc totals:
  94. local pick%,busmil&,persmil&,avtrip&,totmile&
  95.     busmil&=0
  96.     first
  97.     do
  98.     busmil&=busmil&+(A.totb&)
  99.     next
  100.     until eof
  101.     persmil&=0
  102.     first
  103.     do
  104.     persmil&=persmil&+(A.totp&)
  105.     next
  106.     until eof
  107.     dinit
  108.     dtext "","TOTAL MILES RECORDED",$302
  109.     dtext "","Total Business Miles Are "+gen$(busmil&,10)+" Miles."
  110.     dtext "","Total Personal Miles Are "+gen$(persmil&,10)+" Miles."
  111.     dtext "","Total Combined Miles Are "+gen$(busmil&+persmil&,10)+" Miles."
  112. totmile&=busmil&+persmil&
  113. avtrip&=totmile&/count
  114.     dtext "","Average Trip Mileage Is "+gen$(avtrip&,10)+" Miles."
  115.     dtext "","You Have Recorded "+gen$(count,10)+" Trips."
  116.     dialog
  117.     last    REM go to last record
  118.     prompt$=upper$(A.endpos$)
  119.     prompt&=A.endmile&
  120. endp
  121.  
  122. proc domenu:
  123. local m%,m$(1)
  124. minit
  125. mcard "ML3","About",%a,"Export",%e,"Totals",%t,"Setup",%s,"Quit",%x
  126. m%=menu
  127. if m%=97    REM About?
  128.     about:
  129. elseif m%=101    REM Export?
  130.     export:
  131. elseif m%=116    REM Totals?
  132.     totals:
  133. elseif m%=115    REM Setup?
  134.     setup:
  135. elseif m%=120    REM Quit?
  136.     stop
  137. endif
  138. endp
  139.  
  140. proc dopsion:(kv%)
  141. local choice%
  142. choice%=kv%
  143. if choice%=97    REM About selected?
  144.     about:
  145. elseif choice%=101    REM Export File?
  146.     export:
  147. elseif choice%=116    REM Totals?
  148.     totals:    
  149. elseif choice%=115    REM Setup?
  150.     setup:
  151. elseif choice%=120    REM Quit?
  152.     stop
  153. endif
  154. endp
  155.  
  156. proc about:
  157. dinit
  158. dtext "","ML3 vers 1.01",$102
  159. dtext "","¸1993 Les Hall",$102
  160. dtext "","CIS 71053,1676",$102
  161. dtext "",chr$(34)+"pax vobiscum"+chr$(34),$101
  162. dialog
  163. endp
  164.  
  165. proc setup:
  166. local choice%,firsloc$(20),firsmil&
  167. beep 1,400 :beep 1,200 :beep 1,400 :beep 1,200
  168. dinit
  169. dtext "","ML3 SETUP - WARNING!",$302
  170. dtext "","You are about to erase or create",2
  171. dtext "","Miles.ODB. Are you sure? Esc, press ",2
  172. dtext "","[Help] then select þSetup if unsure.",2 
  173. dbuttons "Unsure",-27,"Positive",13
  174. choice%=dialog
  175. if choice%=13
  176.     close 
  177.     delete ("M:\Miles.odb")
  178.     create "M:\Miles",A,time$,startpo$,startmi&,endpos$,endmile&,totb&,totp&
  179.     dinit
  180.     dtext "","Enter Initial Location & Mileage",$302
  181.     firsloc$="Home/Work etc"
  182.     dedit firsloc$,"Enter Initial Location:"
  183.     dlong firsmil&,"Enter Initial Mileage :",1,10000000
  184.     dialog
  185.         A.startpo$="Start of ML3 File"
  186.         A.endpos$=firsloc$
  187.         A.endmile&=firsmil&
  188.         A.time$=mid$(datim$,5,17)
  189.         append 
  190. endif
  191. endp
  192.  
  193. proc export:
  194. local busmil&,persmil&
  195. lopen "M:\WRD\milelog.wrd"
  196. busy "Saving Milelog.WRD",3
  197. lprint "MILEAGE LOG EXPORTED ON "+DATIM$
  198. lprint chr$(13)
  199. lprint "This is a tab delimited file. Please set up six tabs to view properly"
  200. lprint "The list below shows what each tab/column represents"
  201. lprint "DATE&TIME    START LOC'    START MILES    END LOC'    END MILES    BUS' MILES    PER' MILES"
  202. lprint chr$(13)
  203. first
  204. while not eof
  205. lprint A.time$+chr$(9)+A.startpo$+chr$(9),A.startmi&,chr$(9)+A.endpos$+chr$(9),A.endmile&,chr$(9),A.totb&,chr$(9),A.totp&
  206. next
  207. endwh
  208. busmil&=0
  209. first
  210. do
  211. busmil&=busmil&+(A.totb&)
  212. next
  213. until eof
  214. lprint chr$(13)
  215. lprint "Total Business Miles Are ";busmil&;" Miles"
  216. persmil&=0
  217. first
  218. do
  219. persmil&=persmil&+(A.totp&)
  220. next
  221. until eof
  222. lprint "Total Personal Miles Are ";persmil&;" Miles"
  223. busmil&=0
  224. persmil&=0
  225. first
  226. do
  227. busmil&=busmil&+(A.totb&)
  228. next
  229. until eof
  230. first
  231. do
  232. persmil&=persmil&+(A.totp&)
  233. next
  234. until eof
  235. lprint "Total Combined Miles Are ";busmil&+persmil&;" Miles"
  236. lprint chr$(13)
  237. lprint "********* END OF MILEAGE LOG *******"
  238. lclose
  239. last
  240. busy off 
  241. endp
  242.  
  243. proc help:
  244. local g%
  245. top::
  246. dinit
  247. dtext ""," Help:ML3",$300
  248. dtext "","þUsing ML3",$500
  249. dtext "","þSetup",$500
  250. dtext "","þExporting",$500
  251. dtext "","þKudos, Thanks",$500
  252. g%=dialog
  253. if g%=0
  254.     return
  255. elseif g%=291
  256.     return
  257. elseif g%=2
  258.     dinit
  259.     dtext "","Help: Using ML3 - Run Setup First!",$300
  260.     dtext "","Press [Enter] to open the trip input",0
  261.     dtext "","dialog box. Enter your current",0
  262.     dtext "","location & then the current mileage. ",0
  263.     dtext "","Then choose whether it was a Business or",0
  264.     dtext "","a Personal trip. All this data is saved",0
  265.     dtext "","to Miles.ODB on Internal memory.",0
  266.     dialog
  267.     goto top::
  268. elseif g%=3
  269.     dinit
  270.     dtext "","Help: ML3 Setup",$300
  271.     dtext "","You must select Setup once before you can",0
  272.     dtext "","use ML3. Either select Setup from the ",0
  273.     dtext "","menu or use Psion-S. You are given the ",0
  274.     dtext "","chance to escape if selected by mistake!",0
  275.     dtext "","Otherwise input your initial location",0
  276.     dtext "","& mileage. Miles.ODB is created on M:",0
  277.     dialog
  278.     goto top::
  279. elseif g%=4
  280.     dinit
  281.     dtext "","Help: Exporting A Mileage Log",$300
  282.     dtext "","When you select Export from the menu or",0
  283.     dtext "","Psion-E from the keyboard, you export a",0
  284.     dtext "","tab-delimited file (Milelog.WRD) to your",0
  285.     dtext "","WRD directory on your Internal memory.",0
  286.     dtext "","Print from there or export it to your",0
  287.     dtext "","Macintosh or PC. Try it out!",0
  288.     dialog
  289.     goto top::
  290. elseif g%=5
  291.     dinit
  292.     dtext "","Help: Kudos, Thanks",$300
  293.     dtext "","First, thanks to Psion Inc & Psion PLC",0
  294.     dtext "","for making such cool little gizmos.",0
  295.     dtext "","Thanks also to all the members of the",0
  296.     dtext "","Palmtop Forum who have shared their",0
  297.     dtext "","ideas & code with their fellow users.",0
  298.     dtext "","Special thanks to Jim, Mark & Rowan.",0
  299.     dialog
  300.     goto top::
  301.  
  302. endif
  303. ENDP
  304.  
  305.